﻿using System;
using System.Collections.Generic;
using System.Text;
using Volo.Abp.Application.Services;
using Rechargeable.Products.Dtos;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Domain.Repositories;
using System.Threading.Tasks;
using System.Linq;

namespace Rechargeable.Products
{
    public class ProductPriceAppService : CrudAppService<
        ProductPrice, ProductPriceDto, Guid, PagedAndSortedResultRequestProductPriceDto,
        CreateUpdateProductPriceDto, CreateUpdateProductPriceDto>, IProductPriceAppService
    {
        public ProductPriceAppService(IRepository<ProductPrice, Guid> repository) : base(repository)
        {

        }

        public override async Task<PagedResultDto<ProductPriceDto>> GetListAsync(PagedAndSortedResultRequestProductPriceDto input)
        {
            //await CreateFilteredQueryAsync(input);

            return await base.GetListAsync(input);
        }

        protected override async Task<IQueryable<ProductPrice>> CreateFilteredQueryAsync(PagedAndSortedResultRequestProductPriceDto input)
        {
            return (await Repository.GetQueryableAsync()).Where(q => q.ProductId == input.ProductId);
        }

    }
}
